<template>
  <div class="settings">
    <van-nav-bar safe-area-inset-top placeholder :title="$t('AdvancedSetting')" left-arrow fixed @click-left="onClickLeft" />
    <van-pull-refresh v-model="isLoading" :pulling-text="$t('PullingText')" :loosing-text="$t('PullingText')" :success-text="$t('refreshSuccee')" @refresh="onRefresh">
      <van-collapse class="marginTop15" v-model="activeNames">
        <van-collapse-item :title="$t('Safety')" name="1">
          <safetyPTVue :deviceType="7" :safety="safety" :reg="9" :key="timer" @getFormData="setSafety"></safetyPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ReactivePower')" name="2">
          <van-form @submit="powerfactorSubmit">
            <van-field
              :value="LocalArr.factMode"
              label="Mode Select"
              readonly
              clickable
              name="picker"
              input-align="right"
              @click="showPowerFact = true"
            />
            <van-popup v-model="showPowerFact" round position="bottom">
              <van-picker
                show-toolbar
                :columns="powerFactors"
                @cancel="showPowerFact = false"
                @confirm="factModeConfirm"
                :confirm-button-text="$t('OK')"
                :cancel-button-text="$t('Cancel')" 
              />
            </van-popup>
            <van-field v-if="factModeCode==1||factModeCode==2"
              v-model="LocalArr.P2Value"
              :label="$t('PFValue')"
              type="number"
              show-error
              name="validator"
              input-align="right"
              error-message-align="right"
              clearable
              :rules="[{ validator:fixedTwo1,message: `${$t('Range')}：0.80-1.00` }]"
            />
            <van-field v-if="factModeCode==3&&(safety==0||safety==1||safety==2||safety==6||safety==7||safety==9||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"
              v-model="LocalArr.P3Value"
              :label="$t('UpperLimit')"
              type="number"
              show-error
              name="validator"
              input-align="right"
              error-message-align="right"
              clearable
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]"
            />
            <van-field v-if="factModeCode==3&&(safety==0||safety==1||safety==2||safety==6||safety==7||safety==9||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"
              v-model="LocalArr.P4Value"
              :label="$t('LowerLimit')"
              type="number"
              show-error
              name="validator"
              input-align="right"
              error-message-align="right"
              clearable
              :rules="[{ validator:fixedTwo2,message: `${$t('Range')}：0.90-1.00` }]"
            />
            <van-field v-if="factModeCode==3&&(safety==0||safety==1||safety==2||safety==6||safety==7||safety==9||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"
              v-model="LocalArr.P5Value"
              :label="$t('PowerLow')"
              type="number"
              show-error
              name="validator"
              input-align="right"
              error-message-align="right"
              clearable
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]"
            />
            <van-field v-if="factModeCode==3&&(safety==0||safety==1||safety==2||safety==6||safety==7||safety==9||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"
              v-model="LocalArr.P6Value"
              :label="$t('PowerUp')"
              type="number"
              show-error
              name="validator"
              input-align="right"
              error-message-align="right"
              clearable
              :rules="[{ validator:fixedTwo3,message: `${$t('Range')}：0.00-1.00` }]"
            />
            <div class="factorBtnBox">
              <van-button block round>{{$t('Save')}}</van-button>
            </div>
          </van-form>
          <pfLockInPointPTVue :setName="'PfLockInPoint'" :setUntil="'%'" :setMin="100" :setMax="110" :setValue.sync="LocalArr.PfLockInPointValue" :reg="89" v-if="isPFP&&safety==24"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="'PfLockOutPoint'" :setUntil="'%'" :setMin="90" :setMax="100" :setValue.sync="LocalArr.PfLockOutPointValue" :reg="90" v-if="isPFP&&safety==24"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('wQuVrateUp')" :setUntil="'%'" :setMin="100" :setMax="110" :setValue.sync="LocalArr.wQuVrateUpValue" :reg="94" v-if="isQu&&(safety==2||safety==6||safety==7||safety==9||safety==21||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('wQuVrateLow')" :setUntil="'%'" :setMin="90" :setMax="100" :setValue.sync="LocalArr.wQuVrateLowValue" :reg="95" v-if="isQu&&(safety==2||safety==6||safety==7||safety==9||safety==21||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('SetQurangeV1')" :setUntil="'%'" :setMin="0" :setMax="60" :setValue.sync="LocalArr.SetQurangeV1Value" :reg="122" v-if="isQu&&(safety==2||safety==22)"></pfLockInPointPTVue>
          <pfLockInPointPTVue :setName="$t('SetQurangeV4')" :setUntil="'%'" :setMin="0" :setMax="60" :setValue.sync="LocalArr.SetQurangeV4Value" :reg="123" v-if="isQu&&(safety==2||safety==22)"></pfLockInPointPTVue>
          <pfLockInPointPT2Vue :setName="$t('bQpower_set')" :setMin="-10000" :setMax="10000" :setValue.sync="LocalArr.bQpower_setValue" :reg="124" v-if="isQSet&&(safety==2||safety==6||safety==7||safety==9||safety==21||safety==22||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)"></pfLockInPointPT2Vue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Grid')" name="3">
          <vacMaxPTVue :setName="$t('OVStage1')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMaxValue" :reg="6"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('OVStage2')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMaxSlowProtectValue" :reg="13" v-if="safety!=32&&safety!=34&&safety!=35&&safety!=36&&safety!=37"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('UVStage1')" :setUntil="'V'" :setMin="'1.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMinValue" :reg="5"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('UVStage2')" :setUntil="'V'" :setMin="'1.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMinSlowProtectValue" :reg="12" v-if="safety!=32&&safety!=34&&safety!=35&&safety!=36&&safety!=37"></vacMaxPTVue>
          <languagePTVue :setName="$t('OV10MinAvgEnable')" :columns="toggleArr" :setValue="LocalArr.OV10EnableValue" :reg="138" v-if="safety!=3&&safety!=8&&safety!=10&&safety!=13&&safety!=14&&safety!=15&&safety!=20&&safety!=21&&safety!=25&&safety!=31&&safety!=38"></languagePTVue>
          <vacMaxPTVue :setName="$t('OV10minset')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :setValue.sync="LocalArr.Grid10MinAverageValue" :reg="11" v-if="safety!=0&&safety!=1&&safety!=3&&safety!=4&&safety!=8&&safety!=10&&safety!=13&&safety!=14&&safety!=15&&safety!=20&&safety!=21&&safety!=25&&safety!=31"></vacMaxPTVue>
          <facMaxPTVue :setName="$t('OFStage1')" :setUntil="'Hz'" :setMin="'45.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMaxValue" :reg="8"></facMaxPTVue>
          <facMaxPTVue :setName="$t('OFStage2')" :setUntil="'Hz'" :setMin="'45.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMaxSlowProtectValue" :reg="15" v-if="safety!=32&&safety!=34&&safety!=35&&safety!=36&&safety!=37"></facMaxPTVue>
          <facMaxPTVue :setName="$t('UFStage1')" :setUntil="'Hz'" :setMin="'45.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMinValue" :reg="7"></facMaxPTVue>
          <facMaxPTVue :setName="$t('UFStage2')" :setUntil="'Hz'" :setMin="'45.00'" :setMax="'65.00'" :setValue.sync="LocalArr.FacMinSlowProtectValue" :reg="14" v-if="safety!=32&&safety!=34&&safety!=35&&safety!=36&&safety!=37"></facMaxPTVue>
          <languagePTVue :setName="$t('FreqROCOF')" :columns="toggleArr" :setValue="LocalArr.FreqROCOFValue" :reg="139" v-if="safety!=32&&safety!=33&&safety!=34&&safety!=35&&safety!=36&&safety!=37"></languagePTVue>
          <vacMaxPTVue :setName="$t('OVStage3')" :setUntil="'V'" :setMin="'100.0'" :setMax="'300.0'" :setValue.sync="LocalArr.VacMiddleSlowProtectValue" :reg="129" v-if="safety==10"></vacMaxPTVue>
          <tripFreVue :setName="'Trip Fre T'" :setUntil="'Ms'" :setValue="tripfreValue" v-if="safety==9"></tripFreVue>
          <tripFreVue :setName="'Trip Volt T'" :setUntil="'Ms'" :setValue="tripvoltValue" v-if="safety==9"></tripFreVue>
          <tripFreVue :setName="'Loss of Mains'" :setUntil="'Ms'" :setValue="lossofmainsValue" v-if="safety==9"></tripFreVue>
          <pfLockInPointPTVue :setName="'T_Start'" :setUntil="'S'" :setMin="15" :setMax="1000" :setValue.sync="LocalArr.TStartValue" :reg="140"></pfLockInPointPTVue>
          <languagePTVue :setName="$t('NeutralLine')" :columns="NeutralLineArr" :setValue="LocalArr.NeutralLineValue" :reg="141"></languagePTVue>
          <pfLockInPointPTVue :setName="$t('Q_3Tau')" :setUntil="'S'" :setMin="60" :setMax="600" :setValue.sync="LocalArr.Q3TauValue" :reg="144" v-if="safety==1"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('H/LVRTFunction')" name="4">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.HLVRTFunctionValue" :reg="145"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ExportControl')" name="5">
          <languagePTVue
            :setName="$t('ExportControl')"
            :columns="toggleArr"
            :setValue="LocalArr.exportEnableCode"
            :reg="96"
            @getFormData="setExportEnable"
            ></languagePTVue>
          <pfLockInPointPTVue :setName="$t('UserValue')" :setUntil="'W'" :setMin="0" :setMax="60000" :setValue.sync="LocalArr.ExportLimitValue" :reg="66" v-if="isExportControl"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('PVConnection')" name="6" style="display:none">
          <languagePTVue :columns="pvConnectArr" :setValue="LocalArr.PvModeCode" :reg="10"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item title="DRM Function" name="7" v-if="safety==2||safety==22">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.DRMFunctionValue" :reg="131"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('LineImpedanceEnable')" name="8" v-if="safety==2||safety==22">
          <languagePTVue
            :columns="toggleArr"
            :setValue="LocalArr.lineImpedanceEnableCode"
            :reg="125"
            @getFormData="setLineImpedanceEnable"
          ></languagePTVue>
          <pfLockInPointPTVue :setName="$t('LineImpedanceEnableFlag')" :setUntil="'Ω'" :setMin="0" :setMax="1000" :setValue.sync="LocalArr.LineImpedanceValue" :reg="126" v-if="isLineImpedanceEnable"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('puFunction')" name="9" v-if="safety==2||safety==22">
          <languagePTVue
            :setName="$t('puFunction')"
            :columns="toggleArr"
            :setValue="LocalArr.puFunctionEnableCode"
            :reg="121"
            @getFormData="setPuFunction"
          ></languagePTVue>
          <vacMaxPTVue :setName="$t('SetV2')" :setUntil="'V'" :setMin="'216.0'" :setMax="'230.0'" :setValue.sync="LocalArr.SetV2Value" :reg="118" v-if="isPu"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('SetV3')" :setUntil="'V'" :setMin="'235.0'" :setMax="'255.0'" :setValue.sync="LocalArr.SetV3Value" :reg="119" v-if="isPu"></vacMaxPTVue>
          <vacMaxPTVue :setName="$t('SetV4')" :setUntil="'V'" :setMin="'244.0'" :setMax="'265.0'" :setValue.sync="LocalArr.SetV4Value" :reg="120" v-if="isPu"></vacMaxPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Pfreq')" name="10" v-if="safety!=3&&safety!=4&&safety!=8&&safety!=13&&safety!=14&&safety!=15&&safety!=25&&safety!=31&&safety!=32&&safety!=33&&safety!=34&&safety!=35&&safety!=36&&safety!=37&&safety!=38">
          <languagePTVue
            :columns="toggleArr"
            :setValue="LocalArr.pfreqEnableCode"
            :reg="132"
            @getFormData="setPfreq"
          ></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('wFreqSetPoint')" name="11" v-if="isPfreq&&(safety==1||safety==6||safety==7||safety==9||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)">
          <facMaxPTVue :setName="$t('wFreqSetPoint')" :setUntil="'Hz'" :setMin="'50.20'" :setMax="'51.00'" :setValue.sync="LocalArr.wFreqSetPointValue" :reg="91"></facMaxPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('wFreqDroopRate')" name="12" v-if="isPfreq&&(safety==1||safety==6||safety==7||safety==9||safety==23||safety==24||safety==26||safety==27||safety==28||safety==29||safety==30)">
          <pfLockInPointPTVue :setName="$t('wFreqDroopRate')" :setUntil="'%'" :setMin="2" :setMax="12" :setValue.sync="LocalArr.wFreqDroopRateValue" :reg="92"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item title="wFreDroopDelayTime (Ms)" name="13" v-if="isPfreq&&safety==24">
          <pfLockInPointPTVue :setMin="0" :setMax="1000" :setValue.sync="LocalArr.wFreDroopDelayTimeValue" :reg="93"></pfLockInPointPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('SoftStart')" name="14" v-if="safety==0||safety==1||safety==2||safety==22">
          <languagePTVue
            :columns="toggleArr"
            :setValue="LocalArr.softStartEnableCode"
            :reg="133"
            @getFormData="setSoftStart"
          ></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('SetWgra')" name="15" v-if="isSoftStart&&(safety==2||safety==22)">
          <facMaxPTVue :setName="$t('SetWgra')" :setUntil="'%'" :setMin="'5.00'" :setMax="'100.00'" :setValue.sync="LocalArr.SetWgraValue" :reg="117"></facMaxPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('ConditionConn')" name="16">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.ConditionConnValue" :reg="134"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('InverterStartStop')" name="17">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.InverterStartStopValue" :reg="142"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('EarthDetect')" name="18">
          <languagePTVue :columns="toggleArr" :setValue="LocalArr.EarthDetectValue" :reg="143"></languagePTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('Reset')" name="19">
          <resetINVEnergyPTVue :setName="$t('ClearInverterHistory')" :reg="30"></resetINVEnergyPTVue>
          <resetINVEnergyPTVue :setName="$t('ResetErrorLogs')" :reg="136"></resetINVEnergyPTVue>
        </van-collapse-item>
        <van-collapse-item :title="$t('NewPassword')" name="20">
          <newPasswordPTVue :setValue.sync="LocalArr.NewPasswordValue" :reg="88"></newPasswordPTVue>
        </van-collapse-item>
      </van-collapse>
    </van-pull-refresh>
  </div>
</template>

<script>
import safetyPTVue from "../../../components/Safety/BDSafetyPT";
import pfLockInPointPTVue from "../../../components/PfLockInPoint/BDPfLockInPointPT";
import vacMaxPTVue from "../../../components/VacMax/BDVacMaxPT";
import languagePTVue from "../../../components/Language/BDLanguagePT";
import facMaxPTVue from "../../../components/FacMax/BDFacMaxPT";
import tripFreVue from "../../../components/TripFre/TripFre";
import resetINVEnergyPTVue from "../../../components/ResetINVEnergy/BDResetINVEnergyPT";
import newPasswordPTVue from "../../../components/NewPassword/BDNewPasswordPT";
import pfLockInPointPT2Vue from '../../../components/PfLockInPoint/BDPfLockInPoint2PT'

export default {
  components: {
    safetyPTVue,
    pfLockInPointPTVue,
    vacMaxPTVue,
    languagePTVue,
    facMaxPTVue,
    tripFreVue,
    resetINVEnergyPTVue,
    newPasswordPTVue,
    pfLockInPointPT2Vue
  },
  data() {
    return {
      isLoading: false,
      timer: "",
      activeNames: [],
      safety: sessionStorage.getItem("safety"),
      showPowerFact: false,
      factorArr: [{text:this.$t('Off'),code:0},{text:this.$t('OverExcited'),code:1},{text:this.$t('UnderExcited'),code:2},{text:this.$t('PF(P)'),code:3},{text:this.$t('Q(u)'),code:4},{text:this.$t('Q-Set'),code:5}],
      powerFactors: [],
      factModeCode: "",
      isPFP: true,
      isQu: true,
      isQSet: true,
      tripfreValue: "",
      tripvoltValue: "",
      lossofmainsValue: "",
      isExportControl: false,
      toggleArr: [this.$t('Disable'),this.$t('Enable')],
      NeutralLineArr:[this.$t('Enable'),this.$t('Disable')],
      pvConnectArr: [this.$t('Comm'), this.$t('Multi')],
      isLineImpedanceEnable: false,
      isPu: false,
      isPfreq: false,
      isSoftStart: false,
      LocalArr: {
        factMode: "",
        P2Value: "",
        P3Value: "",
        P4Value: "",
        P5Value: "",
        P6Value: "",
        PfLockInPointValue: "",
        PfLockOutPointValue: "",
        wQuVrateUpValue: "",
        wQuVrateLowValue: "",
        SetQurangeV1Value: "",
        SetQurangeV4Value: "",
        bQpower_setValue: "",
        VacMaxValue: "",
        VacMaxSlowProtectValue: "",
        VacMinValue: "",
        VacMinSlowProtectValue: "",
        OV10EnableValue: "",
        Grid10MinAverageValue: "",
        FacMaxValue: "",
        FacMaxSlowProtectValue: "",
        FacMinValue: "",
        FacMinSlowProtectValue: "",
        FreqROCOFValue: "",
        VacMiddleSlowProtectValue: "",
        TStartValue: "",
        NeutralLineValue: "",
        Q3TauValue: "",
        HLVRTFunctionValue: "",
        exportEnableCode: "",
        ExportLimitValue: "",
        PvModeCode: "",
        DRMFunctionValue: "",
        lineImpedanceEnableCode: "",
        LineImpedanceValue: "",
        puFunctionEnableCode: "",
        SetV2Value: "",
        SetV3Value: "",
        SetV4Value: "",
        pfreqEnableCode: "",
        wFreqSetPointValue: "",
        wFreqDroopRateValue: "",
        wFreDroopDelayTimeValue: "",
        softStartEnableCode: "",
        SetWgraValue: "",
        ConditionConnValue: "",
        InverterStartStopValue: "",
        EarthDetectValue: "",
        NewPasswordValue: ""
      }
    };
  },
  methods: {
    onClickLeft() {
      this.$router.push({ path: "/bdsetting"});
    },
    factModeConfirm(value, i) {
      this.showPowerFact = false;
      this.LocalArr.factMode = value.text;
      this.factModeCode = value.code;
    },
    fixedTwo1(val) {
      return this.comm.fixedTwo(val, 0.8, 1);
    },
    fixedTwo2(val) {
      return this.comm.fixedTwo(val, 0.9, 1);
    },
    fixedTwo3(val) {
      return this.comm.fixedTwo(val, 0, 1);
    },
    async getData() {
      this.comm.loadingShow();
      let datas = await this.SETAPI.LocalIn({'optType':'ReadSetData','pwd':sessionStorage.getItem('bdPwd')});
      if (datas!=null||datas!=undefined) {
        let dataArr = datas;
        this.safety = dataArr[4];
        sessionStorage.setItem("safety", this.safety);
        this.factModeCode = dataArr[13];
        this.LocalArr.factMode = this.factorArr[this.factModeCode].text;
        /*判断用户的选择*/
        if (dataArr[13] == 3) {
          this.isPFP = true;
        } else {
          this.isPFP = false;
        }
        if (dataArr[13] == 4) {
          this.isQu = true;
        } else {
          this.isQu = false;
        }
        if (dataArr[13] == 5) {
          this.isQSet = true;
        } else {
          this.isQSet = false;
        }
        this.LocalArr.P2Value = dataArr[14]/100;
        this.LocalArr.P3Value = dataArr[15]/100;
        this.LocalArr.P4Value = dataArr[16]/100;
        this.LocalArr.P5Value = dataArr[17]/100;
        this.LocalArr.P6Value = dataArr[18]/100;
        this.LocalArr.PfLockInPointValue = dataArr[96];
        this.LocalArr.PfLockOutPointValue = dataArr[97];
        this.LocalArr.wQuVrateUpValue = dataArr[102];
        this.LocalArr.wQuVrateLowValue = dataArr[103];
        this.LocalArr.SetQurangeV1Value = dataArr[129];
        this.LocalArr.SetQurangeV4Value = dataArr[130];
        this.LocalArr.bQpower_setValue = dataArr[132];
        this.LocalArr.VacMaxValue = dataArr[1]/10;
        this.LocalArr.VacMaxSlowProtectValue = dataArr[8]/10;
        this.LocalArr.VacMinValue = dataArr[0]/10;
        this.LocalArr.VacMinSlowProtectValue = dataArr[7]/10;
        this.LocalArr.OV10EnableValue = dataArr[151];
        this.LocalArr.Grid10MinAverageValue = dataArr[6]/10;
        this.LocalArr.FacMaxValue = dataArr[3]/100;
        this.LocalArr.FacMaxSlowProtectValue = dataArr[10]/100;
        this.LocalArr.FacMinValue = dataArr[2]/100;
        this.LocalArr.FacMinSlowProtectValue = dataArr[9]/100;
        this.LocalArr.FreqROCOFValue = dataArr[152];
        this.LocalArr.VacMiddleSlowProtectValue = dataArr[142]/10;
        this.tripfreValue = dataArr[143];
        this.tripvoltValue = dataArr[144];
        this.lossofmainsValue = dataArr[145];
        this.LocalArr.TStartValue = dataArr[146];
        this.LocalArr.NeutralLineValue = dataArr[154];
        this.LocalArr.Q3TauValue = dataArr[157];
        this.LocalArr.HLVRTFunctionValue = dataArr[158];
        this.LocalArr.exportEnableCode = dataArr[135];
        /*判断用户的选择*/
        if (dataArr[135] == 1) {
          this.isExportControl = true;
        } else {
          this.isExportControl = false;
        }
        this.LocalArr.ExportLimitValue = dataArr[63];
        this.LocalArr.PvModeCode = dataArr[5] - 1;
        this.LocalArr.DRMFunctionValue = dataArr[153];
        this.LocalArr.lineImpedanceEnableCode = dataArr[138];
        /*判断用户的选择*/
        if (this.LocalArr.lineImpedanceEnableCode == 1) {
          this.isLineImpedanceEnable = true;
        } else {
          this.isLineImpedanceEnable = false;
        }
        this.LocalArr.LineImpedanceValue = dataArr[139]/1000;
        this.LocalArr.puFunctionEnableCode = dataArr[131];
        /*判断用户的选择*/
        if (this.LocalArr.puFunctionEnableCode == 1) {
          this.isPu = true;
        } else {
          this.isPu = false;
        }
        this.LocalArr.SetV2Value = dataArr[126]/10;
        this.LocalArr.SetV3Value = dataArr[127]/10;
        this.LocalArr.SetV4Value = dataArr[128]/10;
        this.LocalArr.pfreqEnableCode = dataArr[147];
        /*判断用户的选择*/
        if (this.LocalArr.pfreqEnableCode == 1) {
          this.isPfreq = true;
        } else {
          this.isPfreq = false;
        }
        this.LocalArr.wFreqSetPointValue = dataArr[99]/100;
        this.LocalArr.wFreqDroopRateValue = dataArr[100];
        this.LocalArr.wFreDroopDelayTimeValue = dataArr[101];
        this.LocalArr.softStartEnableCode = dataArr[148];
        /*判断用户的选择*/
        if (this.LocalArr.softStartEnableCode == 1) {
          this.isSoftStart = true;
        } else {
          this.isSoftStart = false;
        }
        this.LocalArr.SetWgraValue = dataArr[125]/100;
        this.LocalArr.ConditionConnValue = dataArr[149];
        this.LocalArr.InverterStartStopValue = dataArr[155];
        this.LocalArr.EarthDetectValue = dataArr[156];
        this.LocalArr.NewPasswordValue = this.comm.showPwd(dataArr[104]);
      } else {
        this.comm.tipsShow("InvNoResponse");
      }
    },
    //获取powerfactor列表
    getPowerFactory() {
      if (this.safety == 2 ||this.safety == 6 ||this.safety == 7 ||this.safety == 9 ||this.safety == 22 ||this.safety == 23 ||this.safety == 24 ||this.safety == 26 ||this.safety == 27 ||this.safety == 28 ||this.safety == 29 ||this.safety == 30) {
        this.powerFactors = [{ text: this.$t('Off'), code: 0 },{ text: this.$t('OverExcited'), code: 1 },{ text: this.$t('UnderExcited'), code: 2 },{ text: this.$t('PF(P)'), code: 3 },{ text: this.$t('Q(u)'), code: 4 },{ text: this.$t('Q-Set'), code: 5 }];
      } else if (this.safety == 0 || this.safety == 1) {
        this.powerFactors = [{ text: this.$t('OverExcited'), code: 1 },{ text: this.$t('UnderExcited'), code: 2 },{ text: this.$t('PF(P)'), code: 3 }];
      } else if (this.safety == 21) {
        this.powerFactors = [{ text: this.$t('Off'), code: 0 },{ text: this.$t('OverExcited'), code: 1 },{ text: this.$t('UnderExcited'), code: 2 },{ text: this.$t('Q(u)'), code: 4 },{ text: this.$t('Q-Set'), code: 5 }];
      } else {
        this.powerFactors = [{ text: this.$t('Off'), code: 0 },{ text: this.$t('OverExcited'), code: 1 },{ text: this.$t('UnderExcited'), code: 2 }];
      }
    },
    //设置安规
    setSafety(data){
      if(data=='success'){
        this.safety=sessionStorage.getItem('safety');
        this.getPowerFactory();
      }
    },
    //设置powerfactor
    async powerfactorSubmit() {
      //处理数据
      let factorData_new={};
      factorData_new.P1Value=this.factModeCode;
      if(this.LocalArr.P2Value!=null&&this.LocalArr.P2Value!=undefined){
        factorData_new.P2Value=this.comm.mulFunction(this.LocalArr.P2Value,100);
      }
      if(this.LocalArr.P3Value!=null&&this.LocalArr.P3Value!=undefined){
        factorData_new.P3Value=this.comm.mulFunction(this.LocalArr.P3Value,100);
      }
      if(this.LocalArr.P4Value!=null&&this.LocalArr.P4Value!=undefined){
        factorData_new.P4Value=this.comm.mulFunction(this.LocalArr.P4Value,100);
      }
      if(this.LocalArr.P5Value!=null&&this.LocalArr.P5Value!=undefined){
        factorData_new.P5Value=this.comm.mulFunction(this.LocalArr.P5Value,100);
      }
      if(this.LocalArr.P6Value!=null&&this.LocalArr.P6Value!=undefined){
        factorData_new.P6Value=this.comm.mulFunction(this.LocalArr.P6Value,100);
      }
      let Datas={
        'num':3,
        'Data':[
          {'reg':24,'val':((factorData_new.P2Value)*256+Number(factorData_new.P1Value))+''},
          {'reg':25,'val':((factorData_new.P4Value)*256+Number(factorData_new.P3Value))+''},
          {'reg':26,'val':((factorData_new.P6Value)*256+Number(factorData_new.P5Value))+''}
        ]
      };
      let params={
        'optType':"setReg",
        'Data':JSON.stringify(Datas),
        'pwd':sessionStorage.getItem('bdPwd')
      };
      this.comm.loadingShow();
      let data = await this.SETAPI.LocalIn(params);
      let newdata = data.substring(0,1);
      if (newdata == "Y") {
        this.comm.toastSuccess();
        /*判断用户的选择*/
        if (this.factModeCode == 3) {
          this.isPFP = true;
        } else {
          this.isPFP = false;
        }
        if (this.factModeCode == 4) {
          this.isQu = true;
        } else {
          this.isQu = false;
        }
        if (this.factModeCode == 5) {
          this.isQSet = true;
        } else {
          this.isQSet = false;
        }
      } else {
        this.comm.toastFail();
      }
    },
    //设置Export Enable
    setExportEnable(data) {
      /*判断用户的选择*/
      if (data == 1) {
        this.isExportControl = true;
      } else {
        this.isExportControl = false;
      }
    },
    //设置LineImpedanceEnable
    setLineImpedanceEnable(data) {
      /*判断用户的选择*/
      if (data == 1) {
        this.isLineImpedanceEnable = true;
      } else {
        this.isLineImpedanceEnable = false;
      }
    },
    //设置PU Function
    setPuFunction(data) {
      /*判断用户的选择*/
      if (data == 1) {
        this.isPu = true;
      } else {
        this.isPu = false;
      }
    },
    //设置Pfreq
    setPfreq(data) {
      /*判断用户的选择*/
      if (data == 1) {
        this.isPfreq = true;
      } else {
        this.isPfreq = false;
      }
    },
    //设置SoftStart
    setSoftStart(data) {
      /*判断用户的选择*/
      if (data == 1) {
        this.isSoftStart = true;
      } else {
        this.isSoftStart = false;
      }
    },
    onRefresh() {
      this.isLoading = false;
      this.timer = new Date().getTime();
      for (let i in this.LocalArr) {
        this.LocalArr[i] = "";
      }
      this.getData();
      this.getPowerFactory();
    },
  },
  mounted() {
    setTimeout(()=>{
      this.getData();
      this.getPowerFactory();
    },1000);
  },
};
</script>

<style scoped lang="less">
</style>
